#ifndef TC_MAIN_HH
#define TC_MAIN_HH

/** \file Main.hh 
 * Declarations for the exception framework.
 *
 * (c) Copyright Semih Cemiloglu
 * All rights reserved, see COPYRIGHT file for details.
 *
 * $Id: Main.hh 119 2006-06-21 04:57:25Z semihc $
 *
 *
 */


#include <exception>
#include "Frame.hh"



#if TC_DEFINE_MAIN
  // main() is to be defined by the framework 
  int main(int argc, char* argv[]);
#endif

// user's main will be TC_main
int TC_main(int restart, int argc, char* argv[]);


namespace TC {

  //! main() substitute for catching exceptions
  int CatchMain(int argc, char* argv[]);

  //! Primary main() which calls TC_main() and to be called by
  //! CatchMain()
  int PrimaryMain(int argc, char* argv[]);

  //! C++ implementation's unexpected handler
  extern std::unexpected_handler CppImpl_unexpected;

  //! C++ implementation's terminate handler
  extern std::terminate_handler CppImpl_terminate;

  //! Global unexpected handler
  void Global_unexpected();

  //! Global terminate handler
  void Global_terminate();

  //! The enumerated states of the program
  enum RunState {
    RS_NotStarted = 0,
    RS_StaticInit = 1,
    RS_Running = 2,
    RS_Stopped = 3,
    RS_StaticDeinit = 4
  };

  //! Get/Set interface for the running state of the program
  RunState GetRunState();
  RunState SetRunState(RunState rs);

  //! Mimics static initialiation.
  void StaticInit();

  //! Mimics static de-initialization. Linkage is C to be able to
  //! use it with atexit() function.
  extern "C" void StaticDeinit();

} // end namespace





#endif /* TC_MAIN_HH */
